package jdos.gui;

import java.awt.event.KeyEvent;

public class KeyboardKey {
    static public boolean isLeft(Object key) {
        return ((KeyEvent)key).getKeyLocation()==KeyEvent.KEY_LOCATION_LEFT;
    }

    static public boolean isRight(Object key) {
        return ((KeyEvent)key).getKeyLocation()==KeyEvent.KEY_LOCATION_RIGHT;
    }

    static public boolean isNumPad(Object key) {
        return ((KeyEvent)key).getKeyLocation()==KeyEvent.KEY_LOCATION_NUMPAD;
    }

    static public boolean isPressed(Object key) {
        return ((KeyEvent)key).getID()==KeyEvent.KEY_PRESSED;
    }

    static public boolean isReleased(Object key) {
        return ((KeyEvent)key).getID()==KeyEvent.KEY_RELEASED;
    }

    static public int getKeyCode(Object key) {
        return ((KeyEvent)key).getKeyCode();
    }

    static public int translateMapKey(int key) {
        switch (key) {
            case Mapper.MapKeys.MK_f1:case Mapper.MapKeys.MK_f2:case Mapper.MapKeys.MK_f3:case Mapper.MapKeys.MK_f4:
            case Mapper.MapKeys.MK_f5:case Mapper.MapKeys.MK_f6:case Mapper.MapKeys.MK_f7:case Mapper.MapKeys.MK_f8:
            case Mapper.MapKeys.MK_f9:case Mapper.MapKeys.MK_f10:case Mapper.MapKeys.MK_f11:case Mapper.MapKeys.MK_f12:
                key=KeyEvent.VK_F1+(key-Mapper.MapKeys.MK_f1);
                break;
            case Mapper.MapKeys.MK_return:
                key=KeyEvent.VK_ENTER;
                break;
            case Mapper.MapKeys.MK_kpminus:
                key=KeyEvent.VK_MINUS;
                break;
            case Mapper.MapKeys.MK_scrolllock:
                key=KeyEvent.VK_SCROLL_LOCK;
                break;
            case Mapper.MapKeys.MK_pause:
                key=KeyEvent.VK_PAUSE;
                break;
            case Mapper.MapKeys.MK_printscreen:
                key=KeyEvent.VK_PRINTSCREEN;
                break;
            case Mapper.MapKeys.MK_home:
                key=KeyEvent.VK_HOME;
                break;
        }
        return key;
    }

    static boolean ctrAltDel=false;

}
